home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Freeware / Griffith 0.9.8 / griffith-0.9.8-win32.exe / {app} / lib / plugins / movie / PluginMovieOnet.py < prev    next >
Text File  |  2008-11-17  |  5KB  |  162 lines

  1. # -*- coding: utf-8 -*-
  2.  
  3. __revision__ = '$Id: PluginMovieOnet.py 1040 2008-11-15 21:13:49Z mikej06 $'
  4.  
  5. # Copyright (c) 2005-2006 Piotr O┬┐arowski
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. # GNU Library General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
  20.  
  21. # You may use and distribute this software under the terms of the
  22. # GNU General Public License, version 2 or later
  23.  
  24. import gutils
  25. import movie,string
  26.  
  27. plugin_name         = 'Onet'
  28. plugin_description  = 'Onet Film'
  29. plugin_url          = 'film.onet.pl'
  30. plugin_language     = _('Polish')
  31. plugin_author       = 'Piotr O┬┐arowski'
  32. plugin_author_email = '<ozarow+griffith@gmail.com>'
  33. plugin_version      = '1.7'
  34.  
  35. class Plugin(movie.Movie):
  36.     def __init__(self, id):
  37.         self.encode = 'iso-8859-2'
  38.         self.movie_id = id
  39.         self.url = "http://film.onet.pl/%s" % str(self.movie_id)
  40.  
  41.     def get_image(self):
  42.         self.movie_id = '' # problems with decoding polish characters in UTF8 => forget ID
  43.  
  44.         self.image_url = ''
  45.         pos = string.find(self.page, 'alt="Galeria" border=1 src="')
  46.         if pos > 0:
  47.             self.image_url = "http://film.onet.pl/%s" % gutils.trim(self.page[pos:], 'src="', '"')
  48.             return
  49.         pos = string.find(self.page, 'IMG class=pic alt=\"Plakat"')
  50.         if pos > 0:
  51.             self.image_url = "http://film.onet.pl/%s" % gutils.trim(self.page[pos:], 'src="', '">')
  52.  
  53.     def get_o_title(self):
  54.         self.o_title = gutils.trim(self.page, 'class=a2 valign=top width="100%"><B>', '</B>')
  55.         if self.o_title == '':
  56.             self.o_title = self.get_title(True)
  57.  
  58.     def get_title(self, ret=False):
  59.         data = gutils.trim(self.page, '<TITLE>', ' - Onet.pl Film</TITLE>')
  60.         if ret is True:
  61.             return data
  62.         else:
  63.             self.title = data
  64.  
  65.     def get_director(self):
  66.         self.director = gutils.trim(self.page, '<BR>Re\xbfyseria:  ', '<BR>')
  67.         if string.find(self.director, '-->') <> -1:
  68.             self.director = gutils.after(self.director, '-->')
  69.             self.director = gutils.before(self.director,"<!--")
  70.         else:
  71.             self.director = gutils.after(self.director, '<B>')
  72.             self.director = gutils.before(self.director, '</B>')
  73.  
  74.     def get_plot(self):
  75.         pos = string.find(self.page, '<TD class=tym>Tre\xb7\xe6</TD>')
  76.         if pos > 0:
  77.             self.plot = self.page[pos:]
  78.             self.plot = gutils.trim(self.plot, '<DIV class=a2>', '</DIV>')
  79.             return
  80.         pos = string.find(self.page, '>Recenzje</FONT> ')
  81.         if pos > 0:
  82.             self.plot = self.page[pos:]
  83.             self.plot = gutils.trim(self.plot, '<TD class=a1 colspan=3>', '<A class="ar" ')
  84.         else:
  85.             self.plot = ''
  86.  
  87.     def get_year(self):
  88.         self.year = gutils.trim(self.page, 'class=a2 valign=top width="100%">',')<BR>')
  89.         self.year = gutils.after(self.year, '</B> (')
  90.         self.year = gutils.after(self.year, ', ')
  91.  
  92.     def get_runtime(self):
  93.         self.runtime = gutils.trim(self.page, 'color="#666666">czas ',' min.')
  94.  
  95.     def get_genre(self):
  96.         self.genre = gutils.trim(self.page, 'class=a2 valign=top width="100%">', '<BR><SPAN class=a1>')
  97.         self.genre = gutils.after(self.genre, '<BR>')
  98.  
  99.     def get_cast(self):
  100.         self.cast = "<%s" % gutils.trim(self.page,'#FF7902">Obsada<', '<DIV ')
  101.         self.cast = string.replace(self.cast, '</A> - ', _(' as '))
  102.         self.cast = string.replace(self.cast, '<A class=u ', "\n<a ")
  103.         self.cast = string.strip(gutils.strip_tags(self.cast))
  104.         self.cast = self.cast[18:]
  105.  
  106.     def get_classification(self):
  107.         self.classification = ''
  108.  
  109.     def get_studio(self):
  110.         self.studio = ''
  111.  
  112.     def get_o_site(self):
  113.         self.o_site = ''
  114.  
  115.     def get_site(self):
  116.         self.site = self.url
  117.  
  118.     def get_trailer(self):
  119.         self.trailer = ''
  120.  
  121.     def get_country(self):
  122.         self.country = gutils.trim(self.page, 'class=a2 valign=top width="100%">', ')<BR>')
  123.         self.country = gutils.after(self.country,"(")
  124.         self.country = gutils.before(self.country,",")
  125.  
  126.     def get_rating(self):
  127.         self.rating = gutils.trim(self.page, '>Ocena filmu</TD>', 'g\xb3os\xf3w)')
  128.         self.rating = gutils.after(self.rating, '<BR><B>')
  129.         self.rating = gutils.before(self.rating, '/5</B>')
  130.         if self.rating != '':
  131.             self.rating = str( float(self.rating)*2 )
  132.  
  133.     def get_notes(self):
  134.         self.notes = ''
  135.  
  136. class SearchPlugin(movie.SearchMovie):
  137.     def __init__(self):
  138.         self.encode = 'iso-8859-2'
  139.         self.original_url_search    = 'http://film.onet.pl/filmoteka.html?O=0&S='
  140.         self.translated_url_search    = 'http://film.onet.pl/filmoteka.html?O=1&S='
  141.  
  142.     def search(self,parent_window):
  143.         self.open_search(parent_window)
  144.         self.page = gutils.trim(self.page, '>Wynik wyszukiwania<', '<TABLE border=0 cellpadding=0');
  145.         self.page = gutils.after(self.page, '</SPAN></DIV><BR>');
  146.         return self.page
  147.  
  148.     def get_searches(self):
  149.         elements = string.split(self.page, ' class=pic')
  150.         self.number_results = elements[-1]
  151.  
  152.         if (elements[0]<>''):
  153.             for element in elements:
  154.                 self.ids.append(gutils.trim(element, 'class=a2 width="100%"><A href="','" class=u'))
  155.                 element = gutils.trim(element, 'class=u><B>', '</B>')
  156.                 element = gutils.strip_tags(element)
  157.                 self.titles.append(element)
  158.         else:
  159.             self.number_results = 0
  160.  
  161. # vim: fenc=iso-8859-2
  162.